<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>九九乘法表</title>
    <style>
        body{
            font-family: Arial, sans-serif;
            padding: 20px;
        }
        h1{
            color:#333;
            margin-bottom: 20px;
            text-align: left;
        }
        .multiplication-table{
            text-align: left;
            margin-left: 20px;
        }
        .row{
            margin: 5px 0;
            padding: 8px;
        }
        .row.odd{
            background-color: #DDDDDD;
            font-weight: bold;
        }
        .equation{
            display: inline-block;
            margin-right: 15px;
        }
    </style>
</head>
<body>
    <h1>九九乘法表</h1>
    <div class="multiplication-table" id="multiplicationTable"></div>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const table = document.getElementById('multiplicationTable');

            for (let i = 1; i <= 9; i++) {
                const row = document.createElement('div');
                row.className = 'row' + (i % 2 !== 0 ? ' odd' : '');

                for (let j = 1; j <= i; j++) {
                    const equation = document.createElement('span');
                    equation.className = 'equation';
                    equation.textContent = `${j}*${i}=${j*i}`;
                    row.appendChild(equation);

                    // 添加空格分隔，除了最后一个
                    if (j < i) {
                        row.appendChild(document.createTextNode('\u00A0\u00A0'));
                    }
                }

                table.appendChild(row);
            }
        });
    </script>
</body>
</html>